/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 74646
 * Date: 2022-02-16
 * Time: 20:12
 */
class UserException extends Exception{
    public UserException(String message){
        super(message);
    }
}
class PasswordException extends RuntimeException{
    public PasswordException(String message){
        super(message);
    }
}

public class TestDemo3 {
    public static String userName = "admin";
    public static String passWord = "123456";

    public static void login(String userName,String passWord)throws UserException,PasswordException{
        if(!userName.equals("admin")){
            throw new UserException("用户名错误");
        }
        if(!passWord.equals("123456")){
            throw new PasswordException("登录密码错误");
        }
    }
    public static void main(String[] args) {
        try {
            login("admin","123");
        }catch (UserException userException){
            userException.printStackTrace();
            System.out.println("用户名输入错误");
        }catch (PasswordException passwordException){
            passwordException.printStackTrace();
            System.out.println("登录密码输入错误！");
        }
    }
}
